﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Fluent="clr-namespace:Fluent"
                    xmlns:System="clr-namespace:System;assembly=mscorlib">

    <ControlTemplate x:Key="CheckBoxControlTemplate" TargetType="{x:Type Fluent:CheckBox}">
        <Grid>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal" />
                    <VisualState x:Name="MouseOver" />
                    <VisualState x:Name="Pressed" />
                    <VisualState x:Name="Disabled" />
                </VisualStateGroup>
                <VisualStateGroup x:Name="CheckStates">
                    <VisualState x:Name="Checked" />
                    <VisualState x:Name="Unchecked" />
                    <VisualState x:Name="Indeterminate" />
                </VisualStateGroup>
                <VisualStateGroup x:Name="FocusStates">
                    <VisualState x:Name="Focused">
                        <Storyboard />
                    </VisualState>
                    <VisualState x:Name="Unfocused" />
                </VisualStateGroup>
                <VisualStateGroup x:Name="ValidationStates">
                    <VisualState x:Name="Valid" />
                    <VisualState x:Name="InvalidUnfocused">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                    <VisualState x:Name="InvalidFocused">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ValidationErrorElement" Storyboard.TargetProperty="Visibility">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <Visibility>Visible</Visibility>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="validationTooltip" Storyboard.TargetProperty="IsOpen">
                                <DiscreteObjectKeyFrame KeyTime="0">
                                    <DiscreteObjectKeyFrame.Value>
                                        <System:Boolean>True</System:Boolean>
                                    </DiscreteObjectKeyFrame.Value>
                                </DiscreteObjectKeyFrame>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="16" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid HorizontalAlignment="Left" VerticalAlignment="Center">
                <Border x:Name="border"
                        Width="13"
                        Height="13"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}"
                        BorderThickness="{TemplateBinding BorderThickness}">
                    <Grid>
                        <Path x:Name="CheckIcon"
                              Width="7.5"
                              Height="6.9"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Data="M48.4375,110.4375 L51.4995,112.812 L56.3745,107.24883"
                              Fluent:FrameworkHelper.UseLayoutRounding="False"
                              Opacity="0"
                              Stretch="Fill"
                              Stroke="#FF666666"
                              StrokeEndLineCap="Triangle"
                              StrokeStartLineCap="Triangle"
                              StrokeThickness="1.5" />
                        <Rectangle x:Name="IndeterminateIcon"
                                   Width="7"
                                   Height="7"
                                   Opacity="0"
                                   Fill="#FF666666" />
                        <Rectangle x:Name="DisabledVisualElement"
                                   Fill="White"
                                   Opacity="0"
                                   RadiusX="1"
                                   RadiusY="1" />
                    </Grid>
                </Border>
                <Border x:Name="ValidationErrorElement"
                        Margin="1"
                        BorderBrush="#FFDB000C"
                        BorderThickness="1"
                        CornerRadius="1"
                        Visibility="Collapsed">
                    <Grid Width="10"
                          Height="10"
                          Margin="0,-4,-4,0"
                          HorizontalAlignment="Right"
                          VerticalAlignment="Top"
                          Background="Transparent">
                        <Path Margin="0,3,0,0"
                              Data="M 1,0 L5,0 A 2,2 90 0 1 7,2 L7,6 z"
                              Fill="#DDD43940" />
                        <Path Margin="0,3,0,0"
                              Data="M 0,0 L2,0 L 7,5 L7,7"
                              Fill="White" />
                    </Grid>
                </Border>
            </Grid>
            <ContentControl Grid.Column="1" IsTabStop="False" Margin="2,0,0,0">
                <ContentControl.Foreground>
                    <SolidColorBrush x:Name="ContentPresenterWrapperColor" Color="Black" />
                </ContentControl.Foreground>
                <ContentPresenter x:Name="contentPresenter"
                                  Margin="{TemplateBinding Padding}"
                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                  Content="{TemplateBinding Header}"
                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                  RecognizesAccessKey="True" />
            </ContentControl>
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource CheckBoxHoverBorderBrush}" />
                <Setter TargetName="border" Property="Background" Value="{DynamicResource CheckBoxHoverBackgroundBrush}" />
                <Setter TargetName="CheckIcon" Property="Stroke" Value="#FF333333" />
                <Setter TargetName="IndeterminateIcon" Property="Fill" Value="#FF333333" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource CheckBoxPressedBorderBrush}" />
                <Setter TargetName="border" Property="Background" Value="{DynamicResource CheckBoxPressedBackgroundBrush}" />
                <Setter TargetName="CheckIcon" Property="Stroke" Value="#FF000000" />
                <Setter TargetName="IndeterminateIcon" Property="Fill" Value="#FF000000" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter TargetName="contentPresenter" Property="Opacity" Value=".55" />
                <Setter TargetName="DisabledVisualElement" Property="Opacity" Value=".55" />
            </Trigger>
            <Trigger Property="IsChecked" Value="True">
                <Setter TargetName="CheckIcon" Property="Opacity" Value="1" />
            </Trigger>
            <Trigger Property="IsChecked" Value="{x:Null}">
                <Setter TargetName="IndeterminateIcon" Property="Opacity" Value="1" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="EmptyCheckBoxFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="1"
                               SnapsToDevicePixels="true"
                               Stroke="Black"
                               StrokeDashArray="1 2"
                               StrokeThickness="1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="CheckRadioFocusVisual">
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate>
                    <Rectangle Margin="14,0,0,0"
                               SnapsToDevicePixels="true"
                               Stroke="Black"
                               StrokeDashArray="1 2"
                               StrokeThickness="1" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RibbonCheckBoxStyle" TargetType="{x:Type Fluent:CheckBox}">
        <Setter Property="ToolTipService.ShowDuration" Value="30000" />
        <Setter Property="Template" Value="{DynamicResource CheckBoxControlTemplate}" />
        <Setter Property="Background" Value="#FFFDFDFD"/>
        <Setter Property="Foreground" Value="Black" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="BorderBrush" Value="#FFABABAB" />
        <Setter Property="Margin" Value="2,2,2,2" />
    </Style>

    <Style BasedOn="{StaticResource RibbonCheckBoxStyle}" TargetType="{x:Type Fluent:CheckBox}" />
</ResourceDictionary>